import Vue from 'vue'
import "lib-flexible/flexible" //rem模块
import App from './App.vue'
import router from './router'
import store from './store'

Vue.config.productionTip = false

// 引入字体图标
import "./assets/font/iconfont.css"; //本地引入

// https://vant-ui.github.io/vant/v2/#/zh-CN/quickstart
// $cnpm i vant@latest-v2 -S
// $cnpm i babel-plugin-import -D
import { Swipe, SwipeItem,Sticky,Circle,Slider,Toast,Tab, Tabs ,field,form,button} from 'vant';
Vue.use(Swipe).use(SwipeItem).use(Sticky).use(Circle).use(Slider).use(Toast).use(Tab).use(Tabs).use(field).use(form).use(button);

// $cnpm i swiper@5 -S
import "swiper/css/swiper.min.css"

// 引入 remjs文件
import "./assets/js/rem.js"

/* eslint-disable no-new */
 

//登录拦截
router.beforeEach((to,from,next)=>{
  if (to.meta.requireAuth) {//requireAuth若为true则该路由需要判断是否登录
    if (localStorage.userName) {//判断当前的userName数据是否存在
      next();
    }
    else {
      next({//返回登录页面
        path: 'login',
        query: {redirect: to.fullPath}
      })
    }
  }
  else {
    next();
  }
})


new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
